package test.web.service.impl;

import org.springframework.stereotype.Service;
import test.web.dao.ArriveOrderDao;
import test.web.entity.ArriveOrderEntity;
import test.web.service.ArriveOrderService;

import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

/**
 * @Author piaoransheng
 * @Date 2021/12/8 16:43
 */
@Service
public class ArriveOrderServiceImpl implements ArriveOrderService {
    private final ArriveOrderDao arriveOrderDao;

    public ArriveOrderServiceImpl(ArriveOrderDao arriveOrderDao) {
        this.arriveOrderDao = arriveOrderDao;
    }

    @Override
    public void add(ArriveOrderEntity arriveOrderEntity) {
        arriveOrderEntity.setId(UUID.randomUUID().toString().replace("-", ""));
        arriveOrderEntity.setStatus(1);
        arriveOrderEntity.setApplyTime(LocalDateTime.now());
        arriveOrderDao.save(arriveOrderEntity);
    }

    @Override
    public List<ArriveOrderEntity> findByStatus(int status) {
        return arriveOrderDao.findByStatus(status);
    }
}